package buttons;

import java.util.ArrayList;

import processing.core.PApplet;
import utilities.EventListener;
import buttons.control.C_PopUpMenu;
import buttons.view.V_PopUpMenu;

public class PopUpMenu
{
  private ArrayList<MenuItem> items;
  private V_PopUpMenu vMenu;
  private C_PopUpMenu cMenu;
  //Create:
  public PopUpMenu(PApplet p)
  {
    items = new ArrayList<MenuItem>();
    vMenu = new V_PopUpMenu(this);
    cMenu = new C_PopUpMenu(vMenu, this);
    vMenu.useFont(p);
  }
  public void addItem(String name)
  {
     MenuItem obj = new MenuItem(name);
     items.add(obj); //= (MenuItem[])append(items, obj);
     vMenu.calcWidth(obj); 
  }
  public void removeAll() {
     items = new ArrayList<MenuItem>(0);
  }
  public void addSubscriber(EventListener obj) {
    cMenu.addSubscriber(obj);
  }
  //Run:
  public void onInteract(float mouseXLoc, float mouseYLoc, String interID)
  {
    cMenu.onInteract(mouseXLoc, mouseYLoc, interID);
  }
  public void display(PApplet p)
  {
    vMenu.display(p);
  }
  // Access:
  public ArrayList<MenuItem> getMenuItems()
  {
    return items;
  }
  public C_PopUpMenu getController()
  {
    return cMenu;
  }
  public V_PopUpMenu getView()
  {
    return vMenu;
  }
  public void setXLoc(float val){
    vMenu.setXLoc(val);
  }
  public void setYLoc(float val){
    vMenu.setYLoc(val);
  }
}
